<script>
	const chatIM = require('./xilu/chat.js');
    export default {
        onLaunch: function() {
			let app = this;
			app.$core.onRequestComplete(function (ret, response) {
				if(ret && ret.code===401) {
					if(app.$core.getUserinfo()) {
					  app.$core.logout();
					  uni.navigateTo({url: '/pages/login/login'});
					  uni.showToast({title: '登录过期,请重新登录',icon:'none'});
					}
			   }
			});
			setTimeout(function () {
				  // app初始化完成后再执行
				  let userinfo = app.$core.getUserinfo();
				  if (userinfo) {
					  app.globalData.userinfo =  userinfo;
				  	  chatIM.connectSocket();
				  }
				  app.$core.get({url:'xilumarket.common/init_config',data:{},loading:false,success:(ret)=>{
					app.globalData.config = ret.data.config;
					app.globalData.chat_config.emoList = ret.data.emo
				  }})
				  
				  //1.定位
				  app.$core.getLocation();
			},1);
			
        },
        onShow: function() {
            console.log('App Show')
        },
        onHide: function() {
            console.log('App Hide')
        },
		globalData: {
			isIos: false,
			platformStatus: 1,
			statusBarHeight: 20,
			//小程序配置的接口请求域名，为项目部署的服务器路径
			appid: 'wx6253bbc447cfbd3a',
			wsDomain: 'wss://xilupt.funyog.com:8183',
			// wsDomain: 'wss://xilupt.funyog.com:8282',
			apiBaseUri: "https://xilupt.funyog.com/api",
			////前端上传图片补全域名，如oss的https://xxxx.oss-cn-shanghai.aliyuncs.com，或https://your.site.com
			storageBaseUri: "",
		
			 //阿里OSS的上传路径
			uploadOssStatus: false,
			alioss: {endpoint:''},
			config:{
				logo:''
			},
			userinfo:null,
			chat_config: {
				SocketTask: null,
				Timer: null,
				ErrorMsg: [],
				MaxRetryCount: 30, // 最大重连次数
				CurrentRetryCount: 0,
				ortherdata: null, //其他通用数据
				emoList:[], //表情
				messageCount:0, //未读消息数
			},
			Event: {
				CurrentCityChange: "currentCityChange",
				CurrentCityChange2: "currentCityChange2"
			},
			defaultCity:{
				id: 104,
				name: '上海市'
			},
		},
    }
</script>

<style>
    /*每个页面公共css */
    @import "@/static/style.css";
</style>
